package com.kk.score.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * @author KK
 * @email 409592048@qq.com
 * @date 2022-11-02 12:28:00
 */
@Data
@NoArgsConstructor
@TableName("grade")
public class GradeEntity extends SuperEntity<GradeEntity> {
    private static final long serialVersionUID = 1L;

    /**
     * 需要评价的用户uid
     */
    private String userUid;

    /**
     * 任务uid
     */
    private String pushUid;

    /**
     * 开始时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date startTime;

    /**
     * 结束时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date endTime;

    /**
     * 用户的评分等级 1=不满意，2=基本满意，3=满意
     */
    private Integer score;

    /**
     * 还能修改的次数
     */
    private Integer count;

    /**
     * 评价内容
     */
    private String context;

    /**
     * 用户评分-完成时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date completeTime;

    /**
     * status == 0=未完成，1=完成，2=已过期
     */
    public GradeEntity(Date startTime, Date endTime, String pushUid) {
        this.startTime = startTime;
        this.endTime = endTime;
        setUpdateTime(new Date());
        this.pushUid = pushUid;
    }

    public GradeEntity(String uid, String context, int score, Date date, int status) {
        setUid(uid);
        setContext(context);
        setScore(score);
        setCompleteTime(date);
        setUpdateTime(date);
        setStatus(status);
    }

    public GradeEntity(String uid, Integer score) {
        Date date = new Date();
        setUid(uid);
        setScore(score);
        setStatus(1);
        setCompleteTime(date);
        setUpdateTime(date);
    }
}
